home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10985 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.3 KB

  1. Path: news.sinet.slb.com!usenet
  2. From: "Vinh D. Nguyen" <vnguyen@sugar-land.anadrill.slb.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: passing filenames by ref
  5. Date: Mon, 11 Mar 1996 18:32:37 -0600
  6. Organization: Schlumberger Anadrill
  7. Message-ID: <3144C625.79E@sugar-land.anadrill.slb.com>
  8. References: <HpARxor+BgbR090yn@delta1.deltanet.com>
  9. NNTP-Posting-Host: 163.185.118.40
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (WinNT; I)
  14.  
  15. Tom D. Baccanti wrote:
  16. > I am a new blind student learning c++ and am having some trouble
  17. > understanding the way to pass in a filename by reference.  If I could get a
  18. > simple example to look at I will understand it better.  If this is too basic
  19. > of a question please disregard.  And yes I am using a screen reader and
  20. > compiling from the dos command line with borland 4.52.  Thanks, Tom Baccanti
  21. > --
  22. > Tom D. Baccanti       /** Reach me at Internet:  TDB@Deltanet.com
  23. > Pay a visit to the Outpost today at http://www.deltanet.com/users/tdb
  24. > You can capture my PGP public key by pointing your finger to tdb@deltanet.com
  25.  
  26. I am not sure what you mean by passing a filename by reference. If you use a null-
  27. terminated string to store your file name, then you would pass it by address. Or if you
  28. use a string class such as MFC's CString or something equivalent in BC++, then you can 
  29. do it either of two ways. You can pass a reference to the string into the function as follows:
  30.  
  31. func( CString & strMyString )
  32.  
  33. Or more securely if you don't want to content of your string to be modifiable inside
  34. the function:
  35.  
  36. func( const CString & strMyString )
  37.  
  38. The other way is to typecast your CString object into a null-terminated string before
  39. passing it into the function. It's been ages since I last used BC++, so I don't remember if 
  40. there is such a conversion operator for BC++'s string class.
  41.  
  42. Good luck with your studies.
  43. -- 
  44. --------------------------------------------------------------------------
  45. * Vinh Nguyen                                            vnguyen@slb.com *
  46. * Drilling Information Products - Senior Engineer                        *
  47. * 200 Gillingham Ln.                             (713) 275-7524 (Office) *
  48. * Sugarland, TX 77478                            (713) 275-8098 (FAX)    *
  49. --------------------------------------------------------------------------
  50.